package gui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.event.MouseEvent;
import java.awt.Insets;
import java.awt.Font;

public class MetricsResultWindow extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private final JLabel resultLabel;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			MetricsResultWindow dialog = new MetricsResultWindow();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public MetricsResultWindow() {
		setTitle("Reactivity Value");
		setBounds(100, 100, 450, 186);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		GridBagLayout gbl_contentPanel = new GridBagLayout();
		gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0, 0};
		gbl_contentPanel.rowHeights = new int[]{0, 0, 0};
		gbl_contentPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		contentPanel.setLayout(gbl_contentPanel);
		{
		    JLabel label = new JLabel("    ");
		    GridBagConstraints gbc_label = new GridBagConstraints();
		    gbc_label.insets = new Insets(0, 0, 5, 5);
		    gbc_label.gridx = 1;
		    gbc_label.gridy = 0;
		    contentPanel.add(label, gbc_label);
		}
		{
			JLabel lblReactivity = new JLabel("Reactivity:");
			lblReactivity.setFont(new Font("Tahoma", Font.BOLD, 11));
			GridBagConstraints gbc_lblReactivity = new GridBagConstraints();
			gbc_lblReactivity.insets = new Insets(0, 0, 0, 5);
			gbc_lblReactivity.gridx = 1;
			gbc_lblReactivity.gridy = 1;
			contentPanel.add(lblReactivity, gbc_lblReactivity);
		}
		{
			resultLabel = new JLabel("");
			GridBagConstraints gbc_label = new GridBagConstraints();
			gbc_label.gridx = 3;
			gbc_label.gridy = 1;
			contentPanel.add(resultLabel, gbc_label);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
				okButton.addMouseListener(new java.awt.event.MouseAdapter() {
		            public void mouseClicked(java.awt.event.MouseEvent evt) {
		                okButtonClicked(evt);
		            }
		        });
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
				cancelButton.addMouseListener(new java.awt.event.MouseAdapter() {
		            public void mouseClicked(java.awt.event.MouseEvent evt) {
		                cancelButtonClicked(evt);
		            }
		        });
			}
		}
	}

	protected void cancelButtonClicked(MouseEvent evt) {
		this.dispose();
	}

	protected void okButtonClicked(MouseEvent evt) {
		this.dispose();
	}
	
	public void setValue(Double value) {
		resultLabel.setText(Double.toString(value));
	}

}
